def load_bert_data(path, use_segment, num_examples=None):
    lines = open(path, 'r', encoding='utf-8').read().strip().split('\n')
    src_trg_lines = []

    for line in lines[:num_examples]:
        terms = line.split('\t')
        if len(terms) != 2:
            continue
        src = terms[0].replace(' ', '') if use_segment else terms[0]
        trg = terms[1].replace(' ', '') if use_segment else terms[1]
        src_trg_lines.append([src, trg])
    return src_trg_lines


if __name__ == '__main__':
    path = 'data/train.txt'
    use_segment = False
    src_trg_lines = load_bert_data(path, use_segment)
    print(src_trg_lines)
